import java.io.ByteArrayOutputStream;
import java.io.IOException;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;


@XmlRootElement(name="person")
public class Person {

	/* for marshaling purposes */
	@Deprecated
	public Person() {	}
	
	public Person(int id, String name) {
		this.id = id;
		this.pname = name;
	}
	@XmlElement(name = "preson.id")
    public Integer id;
	
    @XmlElement(name = "preson.name")
    public String pname;
	
	public static void main(String[] args) {
//		makePerson();
		makeStudent();
		System.out.println("\ndone");
	}

	public static void makeStudent() {
		try {
			Student a = new Student(444, "james", 86.99);
			System.out.println(a);
			System.out.println();
			
			ByteArrayOutputStream outStream = new ByteArrayOutputStream(1024);
			MarshelUtil.marshal(a, outStream);
			String xmlString = outStream.toString();
			System.out.println(xmlString);
			
			Student ab = MarshelUtil.unmarshal(xmlString, Student.class);
			
			System.out.println(ab);
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void makePerson() {
		try {
			Person a = new Person(1111, "pele");
			
			ByteArrayOutputStream outStream = new ByteArrayOutputStream(1024);
			MarshelUtil.marshal(a, outStream);
			String xmlString = outStream.toString();
			System.out.println(xmlString);
			
			Student ab = MarshelUtil.unmarshal(xmlString, Student.class);
			
			System.out.println(ab);
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	@Override
	public String toString() {
		return getClass() + " pid = " + id + "  / name = " + pname;
	}
}

